package com.web.hawaste.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.web.hawaste.domain.WorkOrderDetailDo;
import com.web.hawaste.domain.WorkerOrderDo;
import com.web.hawaste.service.IWorkOrderService;
import com.web.hawaste.utils.PageInfo;
import com.web.hawaste.utils.ResultBean;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Suzy
 * @since 2022-09-26
 */
@RestController
@RequestMapping("/manager/work")
public class WorkOrderController {
    @Autowired
    private IWorkOrderService workOrderService;

    @GetMapping("/select/{current}/{size}")
    @RequiresPermissions("work:select")
    public ResultBean<Page> select(@PathVariable Integer current, @PathVariable Integer size, @RequestParam Map<String, Object> params) {
        PageInfo<WorkerOrderDo> pageInfo = (PageInfo<WorkerOrderDo>) workOrderService.selectByCondition(new PageInfo<WorkerOrderDo>(current, size), params);
        pageInfo.setNavigatePage(); // 设置分页导航栏数据
        return ResultBean.ok(pageInfo);
    }

    @GetMapping("/selectOne/{oid}")
    @RequiresPermissions("work:detail")
    public ResultBean selectOne(@PathVariable Long oid) {
        WorkOrderDetailDo workOrderDetailDo = workOrderService.selectDetailById(oid);
        return ResultBean.ok(workOrderDetailDo);
    }
}
